package com.cheyun.netsalev3.repository.aftersale

import com.cheyun.netsalev3.bean.aftersale.DriveDetail
import com.cheyun.netsalev3.utils.api.ApiCallback
import com.cheyun.netsalev3.utils.api.ApiClient
import com.cheyun.netsalev3.utils.api.ApiException
import com.cheyun.netsalev3.utils.api.BaseResp
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import kotlin.reflect.KFunction1

class DriveDetailsRepository(var id: Int) {
    /**
     * 获取详情
     */
    fun getData(ReturnData: KFunction1<@ParameterName(name = "item") DriveDetail,  Unit>) {
        ApiClient.getInstance().getAftersaleDriveDetail(id)
                .subscribeOn(Schedulers.io())
                .subscribeOn(AndroidSchedulers.mainThread())
                .subscribe(object : ApiCallback<BaseResp<DriveDetail>>() {
                    override fun onSuccess(t: BaseResp<DriveDetail>) {
                        t.data?.apply {
                            ReturnData(this)
                        }
                    }

                    override fun onError(ex: ApiException) {

                    }

                })
    }




}